/**
 * 
 */
package com.amkai.aes.webservice.binary.objecthandler;

import java.io.Serializable;

import com.amkai.aes.aescommon.service.binary.job.ClientSettingsJob;
import com.amkai.aes.aescommon.service.result.ClientSettingsResult;
import com.amkai.aes.generatedbeans.system.SystemInformation;
import com.amkai.aes.webservice.binary.JobObjectHandler;
import com.amkai.common.extensions.hibernate.config.SiteManager;
import com.amkai.common.extensions.hibernate.config.manager.SessionManager;

/**
 * @author KeriKornel
 *
 */
// KKORNEL: AES-17127
public class ClientSettingsHandler implements JobObjectHandler<ClientSettingsJob, Serializable, ClientSettingsResult> {

	@Override
	public ClientSettingsResult process(ClientSettingsJob job, Serializable object) throws Exception {
		SessionManager sm = SiteManager.Start();
		ClientSettingsResult result = new ClientSettingsResult(); 
		try {
			SystemInformation si = (SystemInformation)sm.execute("FROM SystemInformation").uniqueResult();
			result.setFreePerTotalRatio(si.getFreePerTotalRatio());
			result.setTotalPerMaxRatio(si.getTotalPerMaxRatio());
		} finally {
			sm.closeSession();
		}
		return result;
	}

}
